<?php
header('content-type:text/html; charset=UTF-8');

$pdo=new PDO('mysql:dbname=mydb3;charset=utf8','root');
$star=$pdo->prepare('select * from user ');
$star->execute();
$data=$star->fetchAll(PDO::FETCH_NAMED);
var_dump($data);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title>通讯录</title>
	</head>
	<body>
		<form  >
			<table border="1" align="center">
				<tr align="center">
					<th colspan="6">通讯录列表</th>
				</tr>
			<?php for($i=0;$i<count($data);$i++){?>
				<tr align="center" >
					<td width="100"><?php echo $data[$i]['id'];?></td>
					<td width="100"><?php echo $data[$i]['qq'];?></td>
					<td width="100"><?php echo $data[$i]['name'];?></td>
					<td width="100"><?php echo $data[$i]['phone'];?></td>
					<td width="50"><a href="shanchu.php?id=<?php echo $data[$i]['id'];?>">删除</a></td>
					<td width="50"><a href="bianji.php?id=<?php echo $data[$i]['id'];?>">编辑</a></td>
				</tr>
			<?php }?>
				<tr>
					<td align="center"><a href="tianjia.php">添加</a></button></td>
				</tr>
			</table>
		</form>
	</body>
</html>